package com.linkoog.devtools.code_generator.database.domain;

public class TypeMapping {

    private DbType dbType;
    private String columnType;
    private String columnDataType;
    private String javaFieldType;
    private Boolean checked;

    public TypeMapping(){
    }

    public TypeMapping(DbType dbType, String columnType, String columnDataType, String javaFieldType, Boolean checked) {
        this.dbType = dbType;
        this.columnType = columnType;
        this.columnDataType = columnDataType;
        this.javaFieldType = javaFieldType;
        this.checked = checked;
    }

    public static TypeMapping copy(TypeMapping old){
        TypeMapping typeMapping = new TypeMapping();
        typeMapping.dbType = old.dbType;
        typeMapping.columnType = old.columnType;
        typeMapping.columnDataType = old.columnDataType;
        typeMapping.javaFieldType = old.javaFieldType;
        typeMapping.checked = old.checked;

        return typeMapping;
    }


    public DbType getDbType() {
        return dbType;
    }

    public void setDbType(DbType dbType) {
        this.dbType = dbType;
    }

    public String getColumnType() {
        return columnType;
    }

    public void setColumnType(String columnType) {
        this.columnType = columnType;
    }

    public String getColumnDataType() {
        return columnDataType;
    }

    public void setColumnDataType(String columnDataType) {
        this.columnDataType = columnDataType;
    }

    public String getJavaFieldType() {
        return javaFieldType;
    }

    public void setJavaFieldType(String javaFieldType) {
        this.javaFieldType = javaFieldType;
    }

    public Boolean getChecked() {
        return checked;
    }

    public Boolean isChecked() {
        return checked;
    }

    public void setChecked(Boolean checked) {
        this.checked = checked;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        TypeMapping that = (TypeMapping) o;

        if (checked != that.checked) return false;
        if (dbType != that.dbType) return false;
        if (columnType != null ? !columnType.equals(that.columnType) : that.columnType != null) return false;
        if (columnDataType != null ? !columnDataType.equals(that.columnDataType) : that.columnDataType != null) return false;
        return javaFieldType != null ? javaFieldType.equals(that.javaFieldType) : that.javaFieldType == null;
    }

    @Override
    public int hashCode() {
        int result = dbType != null ? dbType.hashCode() : 0;
        result = 31 * result + (columnType != null ? columnType.hashCode() : 0);
        result = 31 * result + (columnDataType != null ? columnDataType.hashCode() : 0);
        result = 31 * result + (javaFieldType != null ? javaFieldType.hashCode() : 0);
        result = 31 * result + (checked ? 1 : 0);
        return result;
    }
}
